/*
 * Copyright (c) 2020 pig4cloud Authors. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.chen.framework.controller;

import com.chen.framework.model.sys.SysAccessLog;
import com.chen.base.module.log.dto.AccessLogDTO;
import com.chen.base.utils.ConvertUtil;
import com.chen.framework.mapper.SysAccessLogMapper;
import com.chen.root.base.R;
import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 日志表 前端控制器
 * </p>
 *
 * @author ChenJinLong
 * @since 2023/7/9
 */
@RestController
@AllArgsConstructor
@RequestMapping("/log")
@Api(value = "log",tags = "日志管理API")
public class LogController {

	private final SysAccessLogMapper sysAccessLogMapper;

	/**
	 * 插入日志
	 * @param accessLogDTO 日志实体
	 * @return success/false
	 */
	@PostMapping
	public R<Boolean> save(@Valid @RequestBody AccessLogDTO accessLogDTO) {
		SysAccessLog sysAccessLog = ConvertUtil.convertor(accessLogDTO, SysAccessLog.class);
		sysAccessLogMapper.insert(sysAccessLog);
		return R.ok(true);
	}
}
